package com.treasure.service.creditCard.controller;

import com.alibaba.fastjson.JSON;
import com.treasure.service.annotation.LogInfo;
import com.treasure.service.creditCard.service.CreditCardService;
import com.treasure.service.dto.ApplyForDto;
import com.treasure.service.dto.bank91.GetBankResult91;
import com.treasure.service.result.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @Description:    与三方办理信用卡对接
* @Author:         panxinwen
* @CreateDate:     2018/11/1 22:31
* @Version:        1.0
*/
@Api(value = "三方对接",description = "与三方办理信用卡对接")
@RestController
@RequestMapping("/creditCard/v1")
public class CreditCardCortroller {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private CreditCardService creditCardService;

    @LogInfo(log = "申请办理信用卡",isPrint = true)
    @RequestMapping("/applyFor")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "realName", value = "姓名", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "certNo", value = "证件号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "bankCode", value = "银行编码", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "渠道(1-91 2-盒鑫)", required = false, dataType = "int", paramType = "query"),
    })
    public ResponseEntity applyFor(@RequestBody ApplyForDto applyForDto){
        logger.info("申请办理信用卡参数：{}",JSON.toJSONString(applyForDto));
        ResponseResult result = creditCardService.applyFor(applyForDto);

        return ResponseEntity.ok(result);

    }

    @LogInfo(log = "查询支持银行",isPrint = true)
    @PostMapping("/getBank")
    public ResponseEntity getBank(){

        GetBankResult91 getBankResult91 = creditCardService.getBank();

        return ResponseEntity.ok(getBankResult91);

    }

    @LogInfo(log = "查询新用户办理进度",isPrint = true)
    @PostMapping("/queryCreditCardSchedule")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "realName", value = "姓名", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "certNo", value = "证件号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "bankCode", value = "银行编码", required = false, dataType = "String", paramType = "query"),
    })
    public ResponseEntity queryCreditCardSchedule(@RequestBody ApplyForDto applyForDto){

        ResponseResult responseResult = creditCardService.queryCreditCardSchedule(applyForDto);

        return ResponseEntity.ok(responseResult);

    }

}
